<!DOCTYPE html>
<html lang="zh">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
<meta name="keywords" content="LightYear,LightYearAdmin,光年,后台模板,后台管理系统,光年HTML模板">
<meta name="description" content="Light Year Admin V5是一个基于Bootstrap v5.1.3的后台管理系统的HTML模板。">
<title>首页 - 后台管理系统模板</title>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-touch-fullscreen" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="default">
<link rel="stylesheet" type="text/css" href="css/materialdesignicons.min.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/style.min.css">
<!--对话框插件css-->
<link rel="stylesheet" type="text/css" href="js/jquery-confirm/jquery-confirm.min.css">
<style>
td>span{
	color: darkgreen;
}
</style>
</head>
  
<body>
<div class="container-fluid">
  <div class="row">
  	<div class="col-lg-12">
  	  <div class="card">
  	    <header class="card-header">
  	      <div class="card-title">教师名单</div>
  	    </header>
  		<div class="card-body">
  		  <div class="table-responsive">
  		    <table class="table table-hover">
  		      <thead>
  		        <tr>
  		          <th>#</th>
  		          <th>姓名</th>
  		          <th>手机</th>
  		          <th>学科</th>
  		          <th>组别</th>
  		          <th>岗位</th>
  		          <th>状态</th>
  		          <th>操作</th>
  		        </tr>
  		      </thead>
  			  <tbody>
				
			  </tbody>
            </table>
  	      </div>
  	    </div>
  	  </div>
    </div>
  </div>
</div>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/popper.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/chart.min.js"></script>
<!-- 数字动态滚动增加效果 -->
<script type="text/javascript" src="js/scroll-numbers.js"></script>
<!--引入chart插件js-->
<script type="text/javascript" src="js/main.min.js"></script>

<!--对话框插件js-->
<script type="text/javascript" src="js/jquery-confirm/jquery-confirm.min.js"></script>
<script type="text/javascript">
$(document).ready(function(e) {
	function reload(){
		$.post('http://c.fe80.cn/shubao/teacher/list',{},function(res){
			if(res.list){
				$.each(res.list,function(index,item){
					let color = {'-1':'success','0':'danger','1':'success'};
					let text = {'-1':'退休','0':'交流','1':'在岗'};
					let html = `<tr>
						<td>`+(index+1)+`</td>
						<td>`+item.name+`</td>
						<td>`+item.phone+`</td>
						<td>`+item.subject+`</td>
						<td>`+item.group+`</td>
						<td>`+item.position+`</td>
						<td><span class="badge bg-`+color[item.status]+`">`+text[item.status]+`</span></td>
						<td dataid="`+item.id+`">
							<button class="btn btn-link btn-round btn-sm">恢复</button>
						</td>`+
						// <td>`+item.name+`</td>
						// <td>`+(item.experiment?'实验班':'普通班')+`</td>`+
						// `<td><span class="badge bg-warning">待定</span></td>
						// <td>
						// 	<div class="progress progress-xs">
						// 	<div class="progress-bar progress-bar-striped bg-warning" style="width: 45%;"></div>
						// 	</div>
						// </td>`
					`</tr>`;
					$('tbody').append(html);
				});
			}
		});
	}
	reload();

	$('tbody').on('click','button',function(){
		let id = $(this).parent().attr('dataid');
		let tr = $(this).parent().parent();

		$.confirm({
			title: '温馨提示',
			content: '确认要恢复该数据吗？',
			icon: 'mdi mdi-comment-question',
			animation: 'scale',
			closeAnimation: 'scale',
			opacity: 0.5,
			buttons: {
				'confirm': {
					text: '确定',
					btnClass: 'btn-blue',
					action: function() {
						$.post('http://c.fe80.cn/shubao/student/borrow_revert',{id:id},function(res){
							if(res.state == 1){
								$.alert('<strong>恢复</strong>成功！',{icon:1});
								tr.remove();
							}else{
								$.alert('<strong>恢复</strong>失败！',{icon:2});
							}
						});
					}
				},
				'取消': function() {}
			}
		});
	})
});
</script>
</body>
</html>